<template>
  <div class="loading-container" :style="{ backgroundColor: background || '' }">
    <div class="loading-content">
      <div class="dot-wrap">
        <span></span>
        <span></span>
        <span></span>
      </div>
      <p v-if="text" class="loading-text">{{ text }}</p>
    </div>
  </div>
</template>
<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
  props: {
    text: {
      type: String,
      default: "loading",
    },
    background: {
      type: String,
    },
  },
});
</script>
<style lang="scss" scoped>
.loading-container {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}
.loading-content {
  position: absolute;
  top: 50%;
  left: 50%;
  text-align: center;
  transform: translate(-50%, -50%);
}
@keyframes loading {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}
//
.dot-wrap span {
  background-color: #ccc;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: inline-block;
}
.dot-wrap span:nth-child(1) {
  animation: loading linear alternate 0.6s infinite 0s;
}
.dot-wrap span:nth-child(2) {
  animation: loading linear alternate 0.6s infinite 0.3s;
}
.dot-wrap span:nth-child(3) {
  animation: loading linear alternate 0.6s infinite 0.6s;
}
.loading-text {
  color: #ccc;
}
</style>
